﻿using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Xinrui.Core.IRepository;
using Xinrui.Core.IServices;
using Xinrui.Core.Models.Models;
using Xinrui.Core.Repository;
using Xinrui.Core.Services;

namespace Xinrui.Core.Controllers
{
    public class AdvertisementController : BaseController
    {
        // GET
        // GET: api/Blog/5
        /// <summary>
        /// 根据id获取数据
        /// </summary>
        /// <param name="id">参数id</param>
        /// <returns></returns>
        [HttpGet("{id}", Name = "Get")]
        public async Task<List<Advertisement>> Get(int id)
        {
            //先实例化AdvertisementRepository
            IAdvertisementRepository advertisementRepository =new AdvertisementRepository();
            //将AdvertisementRepository注入到AdvertisementService
            IAdvertisementService advertisementServices = new AdvertisementService(advertisementRepository);

            return await advertisementServices.Query(d => d.Id == id);
        }
    }
}